{template '_header'}
 <div class='page-header'>
     当前位置：<span class="text-primary">优惠券设置</span>
 </div>
 
<div class="page-content">
    <form id="setform"  action="" method="post" class="form-horizontal form-validate">

        <input type="hidden" name="tab" id='tab' value="{$_GPC['tab']}" />


        <ul class="nav nav-arrow-next nav-tabs" id="myTab">
            <li {if $_GPC['tab']=='basic' || empty($_GPC['tab'])}class="active"{/if} ><a href="#tab_basic">基本</a></li>
            <li {if $_GPC['tab']=='adv'}class="active"{/if} ><a href="#tab_adv">幻灯片</a></li>
            <li {if $_GPC['tab']=='notice'}class="active"{/if} ><a href="#tab_notice">通知</a></li>


        </ul>

        <div class="tab-content">
            <div class="tab-pane  {if $_GPC['tab']=='basic' || empty($_GPC['tab'])}active{/if}" id="tab_basic">{template 'sale/coupon/set/basic'}</div>
            <div class="tab-pane  {if $_GPC['tab']=='adv'}active{/if}" id="tab_adv">{template 'sale/coupon/set/adv'}</div>
            <div class="tab-pane  {if $_GPC['tab']=='notice'}active{/if}" id="tab_notice">{template 'sale/coupon/set/notice'}</div>
        </div>

        <div class="form-group"></div>
        <div class="form-group">
            <label class="col-lg control-label"></label>
            <div class="col-sm-9">
                <input type="submit"  value="提交" class="btn btn-primary" />

            </div>
        </div>


    </form>
</div>
<script language='javascript'>
         require(['bootstrap'],function(){
             $('#myTab a').click(function (e) {
                 e.preventDefault();
                $('#tab').val( $(this).attr('href'));
                 $(this).tab('show');
             })
     });
     
     
	$(function () {
bindEvents();
	})
	function removeAdv(obj){
		$(obj).closest('.adv-item').remove();
	}
	function addAdv(){
		var html='<tr class="adv-item">';
html+='<td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i class="fa fa-arrows"></i></a></td>';
html+='<td>';
html+='<div class="input-group img-item">';
html+='<div class="input-group-addon">';
html+='<img src="" style="height:20px;width:50px" />';
html+='</div>';
html+='<input type="text" class="form-control" name="adv_img[]" />';
html+='<div class="input-group-btn">';
html+='<button type="button" class="btn btn-default btn-select-pic">选择图片</button>';
html+='</div>';
html+='</div>';
html+='</td>';
html+='<td><input type="text" class="form-control" name="adv_url[]" /></td>';
html+='<td><button type="button" class="btn btn-danger  btn-sm" onclick="removeAdv(this)"><i class="fa fa-remove"></i></button>';

html+='</td>';
html+='</tr>';
$('#tbody').append(html);
bindEvents();
	}
	function bindEvents() {
		require(['jquery', 'util'], function ($, util) {
			$('.btn-select-pic').unbind('click').click(function () {
				var imgitem = $(this).closest('.img-item');
				util.image('', function (data) {
					imgitem.find('img').attr('src', data['url']);
					imgitem.find('input').val(data['attachment']);
				});
			});
		});
                require(['jquery.ui'] ,function(){
		$("#tbody").sortable({handle: '.btn-move'});
                })
		
	}
        
</script>

{template '_footer'}